package com.jw.debezuim.common.exception;

import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus;

/**
 * 业务异常类
 */

@Getter
@NoArgsConstructor
public class BusinessException extends RuntimeException {
    private int code;

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(HttpStatus status) {
        super(status.getReasonPhrase());
        this.code = status.value();
    }

    public BusinessException(int code, String msg) {
        super(msg);
        this.code = code;
    }

    public BusinessException(String msg) {
        super(msg);
        this.code = HttpStatus.BAD_REQUEST.value();
    }
}

